﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Fraction : IFormattable
{
    private int numerator;
    private int denominator;

    public int Numerator
    {
        get { return numerator; }
        set { numerator = value; }
    }

    public int Denumerator
    {
        get { return denominator; }
        set { denominator = value; }
    }

    public Fraction(int numerator, int denominator)
    {
        this.numerator = numerator;
        this.denominator = denominator;
    }

    public override string ToString()
    {
        return String.Format("{0}", (decimal)this.numerator / this.denominator);
    }

    public string ToString(string format, IFormatProvider formatProvider)
    {
        switch (format)
        {
            case "N":
                return String.Format("{0}/{1}", this.numerator, this.denominator);
            case "R":
                return String.Format("{0:0.00}",(double)this.numerator/this.denominator);                
            default:
                throw new ArithmeticException("Invalid string format!");
        }
    }
}

